<?php

namespace App\Http\Requests;

/**
 * 微信卡券验证器
 * @package App\Http\Requests
 */
class AdminWxCardPost extends AdminBaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'base.card_type' => 'required',
            'base.card_key' => 'required',
            'base.title' => 'required',
            'base.brand_name' => 'required',
            'base.logo_url' => 'required',
            'base.code_type' => 'required',
            'base.color' => 'required',
            'base.notice' => 'required',
            'base.description' => 'required',
            'base.sku.quantity' => 'integer|min:0',
            'base.date_info.type' => 'required|in:DATE_TYPE_FIX_TIME_RANGE,DATE_TYPE_FIX_TERM',
            'base.date_info.begin_timestamp' => 'required_if:base.date_info.type,DATE_TYPE_FIX_TIME_RANGE',
            'base.date_info.end_timestamp' => 'required_if:base.date_info.type,DATE_TYPE_FIX_TIME_RANGE',
            'base.custom_info.custom_url' => 'nullable|url',
            'base.promotion_info.promotion_url' => 'nullable|url',
            'base.center_info.center_url' => 'nullable|url',
            'member.bonus.bonus_url' => 'nullable|url',
            'member.balance.balance_url' => 'nullable|url',
            'member.custom_field1.url' => 'nullable|url',
            'member.custom_field2.url' => 'nullable|url',
            'member.custom_field3.url' => 'nullable|url',
            'member.activate.activate_url' => 'nullable|url',
            'member.activate.wx_activate_after_submit_url' => 'nullable|url',
            'member.service_statement.url' => 'nullable|url',
            'member.bind_old_card.url' => 'nullable|url',
            'member.custom_cell1.url' => 'nullable|url',
            'member.custom_cell2.url' => 'nullable|url',
            'member.custom_cell3.url' => 'nullable|url',
        ];
    }

    /**
     * 定义错误提示
     * @return array
     */
    public function messages()
    {
        return [
            'base.card_type.required' => '请选择卡券类型',
            'base.card_key.required' => '请填写卡券唯一标识',
            'base.title.required' => '请输入卡券名称',
            'base.brand_name.required' => '请输入商户名字',
            'base.logo_url.required' => '请上传卡券的商户LOGO',
            'base.code_type.required' => '请选择卡券码型',
            'base.color.required' => '请选择券颜色',
            'base.notice.required' => '请输入卡券使用提醒',
            'base.description.required' => '请输入卡券使用说明',
            'base.sku.quantity.integer' => '请输入卡券库存',
            'base.sku.quantity.min' => '请输入卡券库存',
            'base.date_info.type.required' => '请选择有效期设置',
            'base.date_info.type.in' => '请选择正确的有效期设置',
            'base.date_info.begin_timestamp.required_if' => '请选择启用开始时间',
            'base.date_info.end_timestamp.required_if' => '请选择启用结束时间',
            'base.custom_info.custom_url.url' => '使用场景的链接无效',
            'base.promotion_info.promotion_url.url' => '服务场景的链接无效',
            'base.center_info.center_url.url' => '营销场景的链接无效',
            'member.bonus.bonus_url.url' => '查看积分详情外链无效',
            'member.balance.balance_url.url' => '查看余额详情外链无效',
            'member.custom_field1.url.url' => '重要自定义会员信息一跳转外链无效',
            'member.custom_field2.url.url' => '重要自定义会员信息二跳转外链无效',
            'member.custom_field3.url.url' => '重要自定义会员信息三跳转外链无效',
            'member.activate.activate_url.url' => '激活会员卡URL无效',
            'member.activate.wx_activate_after_submit_url.url' => '用户提交信息后跳转链接无效',
            'member.service_statement.url.url' => '会员声明链接无效',
            'member.bind_old_card.url.url' => '绑定老会员链接无效',
            'member.custom_cell1.url.url' => '其他自定义会员信息一跳转外链无效',
            'member.custom_cell2.url.url' => '其他自定义会员信息二跳转外链无效',
            'member.custom_cell3.url.url' => '其他自定义会员信息三跳转外链无效',
        ];
    }
}
